﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;

namespace MyApi.Controllers.Community
{
    /// <summary>
    /// 讨论区API
    /// </summary>
    [Produces("application/json")]
    [Route("api/DiscussApi")]
    public class DiscussApiController : Controller
    { 
        [HttpGet]
        [EnableCors("any")]
        [Route("GetList")]
        public object GetList(int index, int size)
        {
            List<object> list = new List<object>();
            for (int i = 1; i < 100; i++)
            {
                object temp = new { id = i, name = "wbs" + i, title = "文章" + i };
                list.Add(temp);
            }

            List<object> data = list.Skip((index - 1) * size).Take(size).ToList();

            JsonResult json = new JsonResult(new { count = list.Count, list = data });
            return json;
        } 
        
    }
}